<?php

mysql_select_db("sintesi", $conexion);

if (!isset($_SESSION["sessionID"]) && (isset($_POST['nom'])) && (isset($_POST['pass']) && (isset($_POST['email'])))) {

	$email = $_POST['email'];
	$pass = $_POST['pass'];
	//el input usuari es diu nom.
	$usuari = $_POST['nom'];

	include ("comprovacioNPE.php");
	
	

	$consulta = "insert into usuari(alias,contrasenya,email)values('$usuari','$pass','$email')";

	$result = (mysql_query($consulta, $conexion));

	if ($result) {

		$_SESSION["sessionID"] = session_id();
		$_SESSION["username"] = $usuari;
		$consulta="select * from usuari where alias ='$usuari'";
	$sql=mysql_query($consulta, $conexion);
	
	if($row=mysql_fetch_array($sql)){
		$_SESSION["idUsuari"] = $row['idUsuari'];
	}

	}
	
	
	
	

}
?>

